 var ajax=function(request={
    url:"",
    async:true,
    method:"POST",
    param:{},
    responseType:null
},_callback){
    if(request.method==null){
        request.method="POST"
    }
    if(request.async==null){
        request.async=true
    }
    var xmlhttp;    
    if (window.XMLHttpRequest)
    {
        // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    // else
    // {
    //     // IE6, IE5 浏览器执行代码
    //     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    // }
    if(request.responseType!=null&&request.responseType!=""){
        xmlhttp.responseType=request.responseType;
    }
   
    xmlhttp.open(request.method,request.url,request.async);
    xmlhttp.setRequestHeader("Content-type","application/json");
    xmlhttp.send(JSON.stringify(request.param));
    
    if(request.async){
        xmlhttp.onreadystatechange=function()
        {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
          {
            if(xmlhttp.responseType=="blob"){
                _callback(null,xmlhttp);
                return;  
            }
            if(xmlhttp.responseText==null||xmlhttp.responseText==""){
                _callback(null,xmlhttp);
                return;
            }
            _callback(JSON.parse(xmlhttp.responseText),xmlhttp);
          }
        }
        return;
    }
    if(xmlhttp.responseText==null||xmlhttp.responseText==""){
        _callback(null,xmlhttp);
        return;
       }
    _callback(JSON.parse(xmlhttp.responseText),xmlhttp);
}


  export default ajax;